package com.example.demo.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;

import com.example.demo.R;
import com.example.demo.entity.Song;
import com.example.demo.entity.User;

public class UserActivity extends AppCompatActivity {

    private static final String TAG = "UserActivityTAG";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user);
        getExtra();
    }

private void getExtra() {
    String type = getIntent().getStringExtra("from");
    if (type.equals("Serializable")) {
        User user = (User) getIntent().getSerializableExtra("user");
        Log.i(TAG, "用户名：" + user.getUsername() + ";密码：" + user.getPassword());
    } else if (type.equals("Parcelable")) {
        Song song = (Song) getIntent().getParcelableExtra("song");
        Log.i(TAG, "歌手名：" + song.getAuthor() + ";播放数：" + song.getNumber());
    }
}
}